from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
import random
from selenium.webdriver.common.keys import Keys


op = webdriver.ChromeOptions()
op.add_experimental_option('excludeSwitches', ['enable-automation'])
op.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=op)

driver.get("http://wwww.baidu.com")
sleep(2)
ele = driver.find_element(By.CSS_SELECTOR,'#kw')
ele.send_keys("自动化")
sleep(2)
randNumber = random.randint(1,10)
for i in range(randNumber):
    ele.send_keys(Keys.DOWN)
    sleep(1)
ele.send_keys(Keys.ENTER)
sleep(3)
assert "自动化" in driver.page_source


driver.quit()

